package history.study.array;

// 26. 删除有序数组中的重复项:https://leetcode-cn.com/problems/remove-duplicates-from-sorted-array/
public class LeetCode_26 {
    public static void main(String[] args) {
        System.out.println(removeDuplicates(new int[]{1}));
    }

    public static int removeDuplicates(int[] nums) {
        if (nums == null || nums.length<=0) return 0;
        int slow = 0;
        for (int i = 1; i < nums.length; i++) {
            if (nums[slow] != nums[i]) {
                nums[++slow] = nums[i];
            }
        }
        return ++slow;
    }
}
